package com.j.Collection.Question;

import java.util.*;
/**
 * 使用集合存储Worker类型
 * */
public class TestQuestion5 {
    public static void main(String[] args) {
        List<Worker> list=new ArrayList<Worker>();
        HashSet<Worker> set=new HashSet<Worker>();
/*        set.add(new Worker("李四",25,3500D));
        set.add(new Worker("王五",22,3200D));
        set.add(new Worker("王五",22,3200D));*/

        /*list.add(new Worker("张三",18,3000D));
        list.add(new Worker("李四",25,3500D));
        list.add(new Worker("王五",22,3200D));
        list.add(2,new Worker("赵四",24,3300D));
        for(int i=0;i<list.size();i++){
            if (list.get(i).getName().equals("王五")){
                list.remove(i);
            }
        }
        for (Worker w :
                list) {
            System.out.println(w);
        }*/



    }
}
class Worker{
    private Integer age;
    private String name;
    private Double salary;

    public Worker() {
    }

    public Worker( String name,Integer age, Double salary) {
        this.age = age;
        this.name = name;
        this.salary = salary;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getSalary() {
        return salary;
    }

    public void setSalary(Double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "worker{" +
                "name='" + name + '\'' +
                "work"+'}';
    }

    @Override
    public int hashCode() {
        return this.name.hashCode()+this.age.hashCode()+this.salary.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (this==obj) return true;
        if (this.getClass()!=obj.getClass()) return false;
        if (this==null) return false;
        Worker worker=(Worker)obj;
        if (this.name.equals(worker.name) && this.age.equals(worker.age) && this.salary.equals(worker.salary)){
            return true;
        }

        return false;
    }
}